#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:robot
@file: sudoku.py 
@version:
@time: 2023/05/22 
"""


class Solution:
    def dfs(self, board):
        for i in range(9):
            for j in range(9):
                if board[i][j] == 0:
                    for k in '123456789':
                        board[i][j] = int(k)
                        if self.dfs(board) and self.is_values(board, i, j):
                            return True
                        board[i][j] = 0
                    return False
        return True

    def is_values(self, board, x, y):
        for i in range(9):
            if i != x and board[i][y] == board[x][y]:
                return False
        for j in range(9):
            if j != y and board[x][j] == board[x][y]:
                return False
        m, n = 3 * (x // 3), 3 * (y // 3)  # 这里求出的是3*3网格的左上角的坐标
        for i in range(3):
            for j in range(3):
                if (i + m != x or j + n != y) and board[i + m][j + n] == board[x][y]:
                    return False
        return True


while True:
    try:
        board = []
        for i in range(9):
            board.append(list(map(int, input().split())))
        t = Solution()
        t.dfs(board)
        print("输出")
        for j in range(9):
            print(' '.join(list(map(str, board[j]))))
    except:
        break
